//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package weaver.interfaces.util;

import weaver.conn.RecordSet;
import weaver.conn.RecordSetDataSource;
import weaver.general.BaseBean;
import weaver.general.Util;

public class ExpenseCompare extends ExpenseCompareUtil {
    private static String ysxxtable = (new BaseBean()).getPropValue("expense", "ysxxtable");

    public ExpenseCompare() {
    }

    public boolean compareExpense(String workflowid, String ccode, String cexpenseitemcode, String citemcode, String kth, double fyje, String iyear) {
        RecordSetDataSource rsds = new RecordSetDataSource("ZJK");
        RecordSet rs = new RecordSet();
        rsds.execute("select centitycode from EF_EP_V_DEPT where code='" + ccode + "'");
        rsds.next();
        String centitycode = Util.null2String(rsds.getString("centitycode"));
        String sqlWwhere = "";
        if("".equals(centitycode)) {
            sqlWwhere = " and centitycode is null";
        } else {
            sqlWwhere = " and centitycode ='" + centitycode + "'";
        }

        if("".equals(cexpenseitemcode)) {
            sqlWwhere = " and cexpenseitemcode is null";
        } else {
            sqlWwhere = " and cexpenseitemcode ='" + cexpenseitemcode + "'";
        }

        if("".equals(citemcode)) {
            sqlWwhere = " and citemcode is null  ";
        } else {
            sqlWwhere = " and citemcode ='" + citemcode + "'";
        }

        if("".equals(kth)) {
            sqlWwhere = " and citemcode is null  ";
        } else {
            sqlWwhere = " and citemcode ='" + kth + "'";
        }

        rs.execute("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and " + sqlWwhere);
        rs.next();
        double dcurrentamount = Util.getDoubleValue(rs.getString("dcurrentamount"), 0.0D);
        return BigDecimalCalculate.floatCompare(String.valueOf(fyje), String.valueOf(dcurrentamount)) <= 0;
    }

    public boolean compareExpense1(String workflowid, String ccode, String cexpenseitemcode, String citemcode, double fyje, String iyear) {
        RecordSetDataSource rsds = new RecordSetDataSource("ZJK");
        RecordSet rs = new RecordSet();
        rsds.execute("select centitycode from EF_EP_V_DEPT where code='" + ccode + "'");
        rsds.next();
        String centitycode = Util.null2String(rsds.getString("centitycode"));
        System.out.println("fyje===" + fyje);
        System.out.println("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and centitycode='" + centitycode + "' and cexpenseitemcode='" + cexpenseitemcode + "' and citemcode='" + citemcode + "'");
        rs.execute("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and centitycode='" + centitycode + "' and cexpenseitemcode='" + cexpenseitemcode + "' and citemcode='" + citemcode + "'");
        rs.next();
        double dcurrentamount = Util.getDoubleValue(rs.getString("dcurrentamount"), 0.0D);
        return BigDecimalCalculate.floatCompare(String.valueOf(fyje), String.valueOf(dcurrentamount)) <= 0;
    }

    public boolean compareExpense2(String workflowid, String cexpenseitemcode, String kth, double fyje, String iyear) {
        RecordSet rs = new RecordSet();
        rs.execute("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and cexpenseitemcode='" + cexpenseitemcode + "' and centitycode='" + kth + "'");
        new BaseBean().writeLog("=============查询预算SQL："+"select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and cexpenseitemcode='" + cexpenseitemcode + "' and centitycode='" + kth + "'");
        rs.next();
        double dcurrentamount = Util.getDoubleValue(rs.getString("dcurrentamount"), 0.0D);
        new BaseBean().writeLog("=========查询到的预算为："+dcurrentamount);
        return BigDecimalCalculate.floatCompare(String.valueOf(fyje), String.valueOf(dcurrentamount)) <= 0;
    }

    public boolean compareExpense3(String workflowid,String cexpenseitemcode, String kth, double fyje, String iyear) {
        RecordSet rs = new RecordSet();
        rs.execute("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and centitycode='" + kth + "' and cexpenseitemcode = '"+cexpenseitemcode+"'");
        new BaseBean().writeLog("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and centitycode='" + kth + "' and cexpenseitemcode = '"+cexpenseitemcode+"'");
        rs.next();
        double dcurrentamount = Util.getDoubleValue(rs.getString("dcurrentamount"), 0.0D);
        new BaseBean().writeLog("=========查询到的预算为："+dcurrentamount);
        return BigDecimalCalculate.floatCompare(String.valueOf(fyje), String.valueOf(dcurrentamount)) <= 0;
    }

    public boolean compareExpense4(String workflowid, String cexpenseitemcode, double fyje, String iyear) {
        RecordSet rs = new RecordSet();
        System.out.println("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and cexpenseitemcode='" + cexpenseitemcode + "'");
        rs.execute("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and cexpenseitemcode='" + cexpenseitemcode + "'");
        rs.next();
        double dcurrentamount = Util.getDoubleValue(rs.getString("dcurrentamount"), 0.0D);
        return BigDecimalCalculate.floatCompare(String.valueOf(fyje), String.valueOf(dcurrentamount)) <= 0;
    }

    public boolean compareExpense5(String workflowid, String ccode, String cexpenseitemcode, double fyje, String iyear) {
        RecordSetDataSource rsds = new RecordSetDataSource("ZJK");
        RecordSet rs = new RecordSet();
        rsds.execute("select centitycode from EF_EP_V_DEPT where code='" + ccode + "'");
        rsds.next();
        String centitycode = Util.null2String(rsds.getString("centitycode"));
        System.out.println("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and centitycode='" + centitycode + "' and  cexpenseitemcode='" + cexpenseitemcode + "'");
        rs.execute("select dcurrentamount from " + ysxxtable + " where iyear='" + iyear + "' and centitycode='" + centitycode + "' and  cexpenseitemcode='" + cexpenseitemcode + "'");
        rs.next();
        double dcurrentamount = Util.getDoubleValue(rs.getString("dcurrentamount"), 0.0D);
        System.out.println("dcurrentamount==" + dcurrentamount);
        System.out.println("fyje==" + fyje);
        return BigDecimalCalculate.floatCompare(String.valueOf(fyje), String.valueOf(dcurrentamount)) <= 0;
    }
}
